package com.kcyu.sfherp.controller;

import com.kcyu.sfherp.service.WeComService;
import com.kcyu.sfherp.utils.RedisCache;
import com.kcyu.sfherp.utils.ResponseResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@Api(tags="系统接口")
@RequestMapping("/setting")
public class ConfigController {


    @Autowired
    private RedisCache redisCache;

    @Autowired
    private WeComService weComService;

   @GetMapping("/queryNoticeMember")
    public ResponseResult getNoticeMember() {
       List<String> noticeMember = redisCache.getCacheList("noticeMember");
       return new ResponseResult(200, noticeMember);
   }

   @PostMapping("/setNoticeMember")
    public ResponseResult setNoticeMember(@RequestBody Map map) {
       List<String> list = (List<String>) map.get("list");
       redisCache.deleteObject("noticeMember");
       redisCache.setCacheList("noticeMember", list);
        return new ResponseResult(200, "设置成功");
   }

   @GetMapping("/getCompAllMember")
    public ResponseResult getComAllMember() {
       ArrayList<Map> member = weComService.getCompAllMember();
       return new ResponseResult(200, member);
   }

}
